package cn.sciento.transfer.infra.constant;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

public final class Constants {
  public static final String APP_CODE = "hdtt";
  
  public static final String FLAG_Y = "Y";
  
  public static final String FLAG_N = "N";
  
  public static final String PROCESS_EXISTS_PROFILE_NAME = "HDTT.DISABLE_PROCESS_EXISTS_DB";
  
  public enum TableNameSuffix {
    DUMP {
      public String suffix() {
        return "_dump";
      }
    },
    TIME_STAMP {
      public String suffix() {
        Date timeStamp = new Date();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
        String timeField = simpleDateFormat.format(timeStamp);
        Random random = new Random();
        int id = random.nextInt(100);
        return "_" + timeField + "_" + id;
      }
    },
    TLS {
      public String suffix() {
        return "_tl";
      }
    };
    
    public abstract String suffix();
  }
  
  public static final class ErrorCode {
    public static final String INIT_SUBMIT_DISABLE_PROCESS_EXISTS_DB = "error.init.disable_process_exists_db";
    
    public static final String INIT_SUBMIT_ANOTHER_IS_PROCESSING = "error.init.another_is_processing";
    
    public static final String INIT_SQL_PRODUCE_TABLE_INVALID = "error.init_sql.produce_table_invalid";
    
    public static final String KAFKA_CONNECTION_CLOSE_ERROR = "error.kafka.connection_close_failed";
    
    public static final String KAFKA_CONSUMER_SQL_EXECUTE_ERROR = "error.kafka.consumer_sql_execute_error";
    
    public static final String KAFKA_CONSUMER_SQL_OPERATION_ERROR = "error.kafka.consumer_sql_operation_error";
    
    public static final String KAFKA_CONSUMER_SQL_TRANSACTION_ERROR = "kafka.consumer_sql_transaction_error";
    
    public static final String KAFKA_CONSUMER_DATASOURCE_CONNECT_FAILED = "error.kafka.consumer.datasource_connect_failed";
    
    public static final String PRODUCE_CONFIG_EXIST = "error.produce.config.exist";
    
    public static final String PRODUCE_CONFIG_TABLE_NOT_EXIST = "error.produce.config..table.not.exist";
    
    public static final String PRODUCE_CONFIG_DATASOURCE_URL_ERROR = "error.produce.datasource.url.error";
    
    public static final String PRODUCE_CONS_DB_CONFIG_EXIST = "error.cons.db.config.exist";
    
    public static final String PRODUCE_CONFIG_DATASOURCE_CONNECT_ERROR = "error.produce.datasource.connect.error";
    
    public static final String CONS_TENANT_ERROR = "error.cons.tenant.error";
    
    public static final String INIT_TENANT_STATUS_IS_RUNNING = "error.init.tenant.is.running";
    
    public static final String INIT_TENANT_STATUS_IS_COMPLATED = "error.init.tenant.is.completed";
    
    public static final String INIT_DIMENSION_ERROR = "error.dimension.not.matched";
    
    public static final String DB_PERMISSION_CHECK_FAILED = "error.permission.check.failed";
    
    public static final String EXECUTE_SQL_FAILED = "error.sql.bad";
    
    public static final String DDL_IS_INVALID = "error.ddl.invalid";
    
    public static final String TENANT_NOT_EXIST = "error.tenant.not.exist";
    
    public static final String TENANT_CONFIG_REPEAT = "error.tenant.repeat";
  }
  
  public static final class ProcessStatus {
    public static final String PENDING = "PENDING";
    
    public static final String RUNNING = "RUNNING";
    
    public static final String COMPLETE = "COMPLETE";
    
    public static final String ERROR = "ERROR";
  }
  
  public static final class EventProcessStatus {
    public static final String P = "P";
    
    public static final String N = "N";
    
    public static final String R = "R";
    
    public static final String S = "S";
    
    public static final String E = "E";
    
    public static final String ER = "ER";
    
    public static final String ERE = "ERE";
  }
  
  public static final Long KAFKA_CONNECTION_CLOSE_TIMOUT = Long.valueOf(5L);
  
  public static final Integer KAFKA_TENANT_FLAG_N = Integer.valueOf(0);
  
  public static final Integer KAFKA_TENANT_FLAG_Y = Integer.valueOf(1);
  
  public static final Integer KAFKA_TL_FLAG_N = Integer.valueOf(0);
  
  public static final Integer KAFKA_TL_FLAG_Y = Integer.valueOf(1);
  
  public static final String CONSUMER_MSG_STATUS_SKIP = "N";
  
  public static final String CONSUMER_MSG_STATUS_COMPLETE = "C";
  
  public static final Integer DEFAULT_PAGE_SIZE = Integer.valueOf(200);
  
  public static final String ROCKETMQ_GROUP_NAME_DIVIDER = "%";
  
  public static final String MQ_DEFAULT_PRODUCER = "TRANSFER-DEFAULT-PRODUCER";
  
  public static final Long ERROR_EVENT_REPORT_RETRY_TIMES = Long.valueOf(5L);
  
  public static interface SqlAction {
    public static final String INSERT = "INSERT";
    
    public static final String UPDATE = "UPDATE";
    
    public static final String DELETE = "DELETE";
    
    public static final String SELECT = "SELECT";
  }
  
  public static interface SqlType {
    public static final String DATA = "DATA";
    
    public static final String ALTER = "ALTER";
  }
  
  public static final class EventErrType {
    public static final String PRODUCE = "PRODUCE";
    
    public static final String SYNC = "SYNC";
    
    public static final String SEND = "SEND";
    
    public static final String RCV = "RCV";
    
    public static final String CONSUME = "CONSUME";
  }
  
  public enum DabaseName {
    mysql, sqlserver, oracle;
  }
  
  public static final class TopicGenStatus {
    public static final String P = "P";
    
    public static final String R = "R";
    
    public static final String S = "S";
    
    public static final String E = "E";
  }
  
  public static interface ThreadPool {
    public static final String BASIC_TASK_EXECUTOR = "asyncTaskExecutor";
    
    public static final String TRANSFER_SOURCE_TASK_EXECUTOR = "transferSourceTaskExecutor";
    
    public static final String TRANSFER_TARGET_TASK_EXECUTOR = "transferTargetTaskExecutor";
    
    public static final String TRANSFER_DATA_CHECK_EXECUTOR = "transferDataCheckExecutor";
    
    public static final String TRANSFER_DATA_CHECK_SAVE_FILE_EXECUTOR = "transferDataCheckSaveFileExecutor";
  }
  
  public static interface DataCheckType {
    public static final String ALL = "ALL";
    
    public static final String SOURCE_TABLE = "SOURCE_TABLE";
    
    public static final String TARGET_TABLE = "TARGET_TABLE";
  }
  
  public static interface DiffType {
    public static final String NO_DATA_LINE = "NO_DATA_LINE";
    
    public static final String FIELD_VALUE_DIFF = "FIELD_VALUE_DIFF";
    
    public static final String DELETED_DATA_LINE = "DELETED_DATA_LINE";
  }
}
